package com.elvin.wx.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Classname Result
 * @Description 返回json对象
 * @Date 2022/1/5 下午11:25
 * @Created by yuankeyan
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {
    private int status;
    private String msg;
    private T data;

    public Result success(T data) {
        this.data = data;
        this.status = 0;
        this.msg = "操作成功";
        return this;
    }

    public Result success(T data, String successMsg) {
        this.success(data);
        this.msg = successMsg;
        return this;
    }

    public Result fail(T data, String errMsg) {
        this.data = data;
        this.status = 1;
        this.msg = errMsg;
        return this;
    }
}
